package com.example.wanted.service;

import com.example.wanted.model.Question;
import com.example.wanted.repository.QuestionRepository;
import com.example.wanted.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QuestionService {
    final QuestionRepository questionRepository;

    @Autowired
    public QuestionService(@Qualifier("question") QuestionRepository questionRepository) {
        this.questionRepository = questionRepository;
    }

    public void save(Question question){
        questionRepository.save(question);
    }


    public Question findByUser(String user_id) {
        return questionRepository.findByUser(user_id);
    }

    public Question findByQuestionID(Long question_id){
        return questionRepository.findByQuestionID(question_id);
    }

    public Question findByLabel(Integer label) {
        return questionRepository.findByLabel(label);
    }

    public List<Question> getQuestions(){
        return questionRepository.getQuestions();
    }

    public Long findSumQuestion(){return questionRepository.findSumQuestion();} //这个是什么 问题总数 在home展示问题 有分页？没有 那这个东西有啥用
}
